<div align="left"><b><?=translate('remote_tpl_man');?></b><br><br></div>
<?

	$params[sid] = $sid;
	$params[action] = "editRemoteTemplate";
	$url = "$baseURL/$webDIR/?".encode_params($params);

	include('wallet_db.html');

	if (isset($_POST['form_sent']) && $_POST['form_sent'] == 'yes') {
		if (!empty($_POST['template']) && !empty($_POST['color'])) {
			$par['element_type'] = addslashes($_POST['template']);
			$par['color'] = addslashes($_POST['color']);
			//------------------------------------------------------
				$sql['type']='UPDATE';
				$sql['params']=$par;
				$sql['table']='interface_settings';
				$sql['where']="reseller_id='$id' and interface_type = 'template'";
				$sql['options']='';
				$sql['return']='struct';
				#$sql['return']='query';
			//------------------------------------------------------
			if (!$result = sql_exec($sql,$dbh81,'assoc')) {
				$errorMsg = translate('int_error');
				include_once('errorMsg.html');
				exit();
			}
			$okMsg = translate('update_ok');
			include_once('okMsg.html');
		}
	}

	//------------------------------------------------------
		$sql['type']='SELECT';
		$sql['params']='*';
		$sql['table']='interface_settings';
		$sql['where']="reseller_id='$id' and interface_type = 'template'";
		$sql['options']='';
		$sql['return']='struct';
	//------------------------------------------------------
	if (!$result = sql_exec($sql,$dbh81,'assoc')) {
		$result = fix_empty_remote_forms($id,'template');
		if (empty($result)) {
			$errorMsg = translate('int_error');
			include_once('errorMsg.html');
			exit();
		}
	}
	foreach ($result as $value) {
		$interface['template'] = $value['element_type'];
		$interface['color'] = $value['color'];
	}/*
echo "<div align=left><pre>";
print_r($interface);
exit("</pre></div>");*/


	$templ[1]="c g v r y";
	$templ[2]="c g v r y";
	$templ[3]="c g v r y";
?>
<script>
var cur_templ='<?=$template?>';
var cur_color='<?=$color?>';


function sTemplate(t){
	if(t.value==0) return;
	if(cur_templ!=0){
		document.getElementById("ord_"+cur_templ).style.display='none';
		if(cur_color!=0){
			document.getElementById("srch_"+cur_templ+"_"+cur_color).style.display='none';
		}
	}

	cur_templ=t.value;
	document.getElementById('ord_'+t.value).style.display='block';
	document.getElementById('srch_'+cur_templ+"_"+cur_color).style.display='block';
}

function sColors(c){
	if(c.value==0) return;
	if(cur_color!=0){
	document.getElementById("srch_"+cur_templ+"_"+cur_color).style.display='none';
	}
	cur_color=c.value;
	document.getElementById('srch_'+cur_templ+"_"+c.value).style.display='block';
}
</script>
<?
	if ($errorMsg) {
	include_once('errorMsg.html');
	}
	if ($okMsg) {
	include_once('okMsg.html');
	}
	else{
	}
?>
<table class=bTable cellspacing=0>
<tr>
	<th><?=translate('remote_tpl_man');?>
    </th>
</tr>
<tr>
	<td><?=translate('remote_tpl_desc');?></td>
</tr>
</table>
<form action="<?=$url?>" method=POST>
<table>
<br>
<table class=bTable cellspacing=0>
<tr>
	<th colspan=2><?=translate('sel_layout');?></th>
</tr>
<tr>
	<td valign =middle>
		<?=translate('sel_template');?>:<br>
		<select name="template" id='templates' size="5" width=100 onChange="sTemplate(this)">
			<option value='0' ><?=translate('sel_template');?> ... </option>
			<option value='1' <? if ($interface['template'] == 1) echo "selected"; ?>><?=translate('template');?> 1</option>
			<option value='2' <? if ($interface['template'] == 2) echo "selected"; ?>><?=translate('template');?> 2</option>
			<option value='3' <? if ($interface['template'] == 3) echo "selected"; ?>><?=translate('template');?> 3</option>

		</select>
		<br><br><br><br>
		<?=translate('sel_theme');?>:<br>
		<select name="color" id='colors' size="6" onChange="sColors(this)">
			<option value='0' ><?=translate('sel_theme');?> ...</option>
			<option value='c' <? if ($interface['color'] == 'c') echo "selected"; ?>><?=translate('blue');?></option>
			<option value='g' <? if ($interface['color'] == 'g') echo "selected"; ?>><?=translate('green');?></option>
			<option value='r' <? if ($interface['color'] == 'r') echo "selected"; ?>><?=translate('red');?></option>
			<option value='v' <? if ($interface['color'] == 'v') echo "selected"; ?>><?=translate('violet');?></option>
			<option value='y' <? if ($interface['color'] == 'y') echo "selected"; ?>><?=translate('yellow');?></option>
		</select>
	</td>
	<td>
			<?
				while(list($k,$v)=each($templ)){
					($k!=$template) ? $ord_style=" style='display:none' ": $ord_style=" style='display:block' ";
						$tt.="<div id='ord_". $k ."' $ord_style ><img src='images/tn_v". $k ."_order.JPG'></div>";


					$arr=explode(" ",$v);

					foreach($arr as $clr){
						($clr!=$color || $k!=$template) ? $s_style=" style='display:none' ": $s_style=" style='display:block' ";
						$tc.="<div id='srch_".$k."_". $clr ."'  $s_style ><img src='images/tn_v". $k ."_". $clr ."_search.JPG'></div>";
					}

				}
			?>
			<?=$tt?><br>
			<?=$tc?>


	</td>
</tr>
<tr>
	<td align=center colspan=2><input type=submit value ='<?=translate('set_template');?>'>
		<input type="hidden" name="form_sent" value="yes">
	</td>
</tr>
</table>
</form>

<br>
<TABLE border=1 class='bTable' cellspacing='0' width='550'>
<tr>

    <th> <?=translate('ready_2_use');?>: </th>
</tr>
<tr>
     <td> &lt;iframe frameborder='0' style='width:<font color="red">700</font>;height:<font color='red'>800</font>;'
              src='http://www.duoservers.com/?r=<font color='red'><?=$userName;?></font>&plan_to_display=&action=t_order'&gt; &lt;/iframe&gt;<br>
       </td>
</tr>

</table>
<script>
function showExpl(a){

    if(document.getElementById(a).style.display=='block') document.getElementById(a).style.display='none';
    else document.getElementById(a).style.display='block';

}
</script>
<TABLE border=1 class='bTable' cellspacing='0' width='550'>
<tr>
    <th><a href='#' onClick="showExpl('explane1')"> <?=translate('explanation');?>:</a></th>
</tr>
</table>
<div id='explane1' style="display:'none'"><br><br>
<TABLE border=1 class='bTable' cellspacing='0' width='550'>
<tr>
    <th> <?=translate('code');?>: </th>
</tr>

 <tr>
     <td> &lt;iframe frameborder='0' style='width:<font color='red'>WIDTH</font>;height:<font color='red'>HEIGHT</font>;'<br>
       src='http://www.duoservers.com/?r=<font color='red'>ACCOUNT NAME</font>&plan_to_display=<font color='red'>PLAN</font>&action=t_order'&gt;&lt;/iframe&gt;<br>


     </td>
</tr>
<tr>

    <th> <?=translate('params');?>: </th>
</tr>

<tr>
    <td>
    <?=translate('final_text');?>
    <br>
    </td>
</tr>
</TABLE>
</div>
<br><br>

<TABLE border=1 class='bTable' cellspacing='0' width='550'>
<tr>

    <th> <?=translate('ready_2_use_dom_search');?>: </th>
</tr>
<tr>
    <td> &lt;iframe frameborder='0' style='width:<font color="red">700</font>;height:<font color='red'>800</font>;'
      src='http://www.duoservers.com/?r=<font color='red'><?=$userName;?></font>&action=t_domain'&gt; &lt;/iframe&gt;<br>



    </td>
</tr>

</table>
<TABLE border=1 class='bTable' cellspacing='0' width='550'>
<tr>
    <th><a href='#' onClick="showExpl('explane2')"><?=translate('explanation');?>: </a></th>
</tr>
</table>
<div id='explane2' style="display:'none'"><br><br>
<TABLE border=1 class='bTable' cellspacing='0' width='550'>
<tr>
    <th> <?=translate('code');?>: </th>
</tr>

  <tr>
    <td> &lt;iframe frameborder='0' style='width:<font color='red'>WIDTH</font>;height:<font color='red'>HEIGHT</font>;'<br>
      src='http://www.duoservers.com/?r=<font color='red'>ACCOUNT NAME</font>&action=t_domain'&gt;&lt;/iframe&gt;<br>


    </td>
</tr>
<tr>

    <th> <?=translate('params');?>: </th>
</tr>

<tr>
    <td>
    <?=translate('final_text2');?>
    <br>
    </td>
</tr>
</TABLE>
</div></table>
<script language="javascript" type="text/javascript">
var cur_color='c';
sTemplate(document.getElementById('templates'));
sColors(document.getElementById('colors'));

</script>
